package n14.second;
import java.util.*;
public class S04 {
	public static void main(String[] args) {
		List<Student2>list=Arrays.asList(
			new Student2("张三", 21, "水院"),
			new Student2("李四", 21, "郑大"),
			new Student2("王五", 19, "水院"),
			new Student2("杨柳", 22, "河大"),
			new Student2("赵琦", 22, "水院"),
			new Student2("杨柳", 20, "水院")
		);
		
		System.out.println("获取水院的学生，按年龄降序排列，显示其姓名：");
		list.stream()
			.filter(s->s.getSchool().equals("水院"))
			.sorted(Comparator.comparingInt((Student2 s)->s.getAge()).reversed())
			.map(s->s.getName())
			.forEach(System.out::println);
		System.out.println("------------------------");
		list.stream()
		.filter(s->s.getSchool().equals("水院"))
		.sorted(Comparator.comparingInt(Student2::getAge).reversed())
		.map(Student2::getName)
		.forEach(System.out::println);
	}
}
